<template>
	<view>
		<view class="list" v-for="(item,index) in list" :key='index' @click="cljbxx(item)">
			<view class="list1">
				<view>
					<image src="../../static/one1.png" mode="" v-if="item.detectionType=='jb'" class="hs"></image>
					<image v-else :src="https+item.icon" mode="aspectFill" class="hs"></image>
				</view>
				<view class="cen">
					<view class="tit">{{item.detectionTypeName}}</view>
				</view>
			</view>
			
			<view class="list1">
				<view class="ytj" v-if="item.staues==0">未提交</view>
				<view class="ytj act2" v-else-if="item.staues==1">编辑中</view>
				<view class="ytj act1" v-else>已提交</view>
				<image src="../../static/lbgd.png" mode="" class="gd"></image>
			</view>
			
		</view>
		<u-toast ref="uToast" />
		
		
		<view class="tijiao" @click="tijiao">
			提交
		</view>
	</view>
</template>

<script>
	import API from "@/api/business.js"
	export default {
		data() {
			return {
				list:'',
				list1:'',
				detectionCarReportId:'',
				https: getApp().globalData.picturePath,
				detectionOrderId:''
			}
		},
		onShow(){
			console.log(12312312321)
			this.merDetectionOrderDetectionTypes();
		},
		onLoad(option) {
			console.log(option)
			this.detectionCarReportId = option.detectionCarReportId;
			this.detectionOrderId = option.detectionOrderId;
			this.merDetectionOrderDetectionTypes();
			
			// this.detectionOrder()
			
		},
	
		methods: {
			cljbxx(e){
				console.log(e)
				if(e.detectionType=='jb'){
					uni.navigateTo({
						url:'/pagesC/testingListDetails/testingListDetails?detectionOrderId='+this.detectionOrderId+'&detectionCarReportId='+this.detectionCarReportId
					})
				}else{
					uni.navigateTo({
						url:'/pagesC/testDetails/testDetails?typeId='+e.detectionType+'&detectionCarReportId='+this.detectionCarReportId
					})
				}
				
			},
			
			merDetectionOrderDetectionTypes(){
				let that = this;
				let data  = {
					token:uni.getStorageSync('token'),
					detectionCarReportId:this.detectionCarReportId
				}
				API.merDetectionOrderDetectionTypes(data).then(res=>{
					this.list = res.data
					this.list1 = res
					console.log(res)
				})
			},
			tijiao(){
				let that = this;
				var checkFlag = false;
				for(var i = 0;i<this.list.length;i++){
					if(this.list[i].staues!=2){
						checkFlag = true;
					}
				}
				if(checkFlag){
					this.$u.toast('请完成以上所有项目');
				}else{
					let data  = {
						token:uni.getStorageSync('token'),
						detectionCarReportId:this.detectionCarReportId,
						detectionOrderId:this.detectionOrderId,
						vin:this.list1.dataTwo
					}
					API.merDetectionOrderAddCarReport_tj(data).then(res=>{
						console.log(res)
						this.$refs.uToast.show({
							title: '提交成功',
							
						})
						uni.navigateBack({
						    delta: 1
						});
					})
				}
				
			}
			
			// detectionOrder(){
			// 	let that = this;
			// 	let data  = {
			// 		token:uni.getStorageSync('token'),
			// 		detectionOrderId:this.detectionOrderId
			// 	}
			// 	API.merDetectionOrderGetAllCarReport(data).then(res=>{
			// 		this.list = res.data
			// 		console.log(res)
			// 	})
			// }
			
		}
	}
</script>

<style lang="scss" scoped>
	.tijiao{
		background-image: linear-gradient(90deg, #10A098 0%, #0062B6 100%);
		
		width: 666rpx;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		font-size: 36rpx;
		color: #FFFFFF;
		margin: auto;
		border-radius: 44rpx;
		margin-top: 350rpx;
	}
	.list{
		margin: 20rpx 32rpx;
		background: #fff;
		padding: 30rpx 27rpx 9rpx;
		display: flex;
		justify-content: space-between;
		    line-height: 60rpx;
		.list1{
			display: flex;
			justify-content: space-between;
			line-height: 80rpx;
		}
		.leftBg{
			width: 65rpx;
			color: #fff;
			font-size: 28rpx;
			line-height: 40rpx;
			height: 40rpx;
			text-align: center;
			background-image: url('../../static/leftBg.png');
			background-size: 100% 100%;
		}
		.gd{
			width: 10rpx;
			height: 20rpx;
			margin-top: 30rpx;
			margin-right: 20rpx;
		}
		.cen{
			margin-left: 26rpx;
		}
		.tit{
			font-size: 34rpx;
			color: #2C2C2C;
		}
		.tit1{
			font-size: 34rpx;
			color: #2C2C2C;
			letter-spacing: 2.1rpx;
		}
		.text{
			
		}
		.hs{
			width: 70rpx;
			height: 70rpx;
		}
		.ytj{
			font-size: 28rpx;
			color: #999999;
			margin-right: 30rpx;
		}
		.act1{
			color: #42C7E6 !important;
		}
		.act{
			color: #FD7E6E !important;
		}
	}
	
</style>
